Kalyna State Matrix State Matrices use column major format similar to AES. These State matrices need not be of square size, they can contain - 128 , 256 , 512 128, 256, 512 128 , 256 , 512 Bits and each cell in matrix stores 1 1 1 Byte B 128 = b 0 b 8 b 1 b 9 b 2 b 10 b 3 b 11 b 4 b 12 b 5 b 13 b 6 b 14 b 7 b 15 B 256 = b 0 b 8 b 16 b 24 b 1 b 9 b 17 b 25 b 2 b 10 b 18 b 26 b 3 b 11 b 19 b 27 b 4 b 12 b 20 b 28 b 5 b 13 b 21 b 29 b 6 b 14 b 22 b 30 b 7 b 15 b 23 b 31 B_{128} = \begin{array}{|c|c|}
\hline
\mathtt{b_0} & \mathtt{b_8} \\
\hline
\mathtt{b_1} & \mathtt{b_9} \\
\hline
\mathtt{b_2} & \mathtt{b_{10}} \\
\hline
\mathtt{b_3} & \mathtt{b_{11}} \\
\hline
\mathtt{b_4} & \mathtt{b_{12}} \\
\hline
\mathtt{b_5} & \mathtt{b_{13}} \\
\hline
\mathtt{b_6} & \mathtt{b_{14}} \\
\hline
\mathtt{b_7} & \mathtt{b_{15}} \\
\hline
\end{array}
\hspace{5mm}
B_{256} = \begin{array}{|c|c|c|c|}\hline
\mathtt{b_0} & \mathtt{b_8} & \mathtt{b_{16}} & \mathtt{b_{24}} \\
\hline
\mathtt{b_1} & \mathtt{b_9} & \mathtt{b_{17}} & \mathtt{b_{25}} \\
\hline
\mathtt{b_2} & \mathtt{b_{10}} & \mathtt{b_{18}} & \mathtt{b_{26}} \\
\hline
\mathtt{b_3} & \mathtt{b_{11}} & \mathtt{b_{19}} & \mathtt{b_{27}} \\
\hline
\mathtt{b_4} & \mathtt{b_{12}} & \mathtt{b_{20}} & \mathtt{b_{28}} \\
\hline
\mathtt{b_5} & \mathtt{b_{13}} & \mathtt{b_{21}} & \mathtt{b_{29}} \\
\hline
\mathtt{b_6} & \mathtt{b_{14}} & \mathtt{b_{22}} & \mathtt{b_{30}} \\
\hline
\mathtt{b_7} & \mathtt{b_{15}} & \mathtt{b_{23}} & \mathtt{b_{31}} \\
\hline
\end{array} B 128 = b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 B 256 = b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 b 16 b 17 b 18 b 19 b 20 b 21 b 22 b 23 b 24 b 25 b 26 b 27 b 28 b 29 b 30 b 31 B 512 = b 0 b 8 b 16 b 24 b 32 b 40 b 48 b 56 b 1 b 9 b 17 b 25 b 33 b 41 b 49 b 57 b 2 b 10 b 18 b 26 b 34 b 42 b 50 b 58 b 3 b 11 b 19 b 27 b 35 b 43 b 51 b 59 b 4 b 12 b 20 b 28 b 36 b 44 b 52 b 60 b 5 b 13 b 21 b 29 b 37 b 45 b 53 b 61 b 6 b 14 b 22 b 30 b 38 b 46 b 54 b 62 b 7 b 15 b 23 b 31 b 39 b 47 b 55 b 63 B_{512} = \begin{array}{|c|c|c|c|c|c|c|c|}
\hline
\mathtt{b_0} & \mathtt{b_8} & \mathtt{b_{16}} & \mathtt{b_{24}} & \mathtt{b_{32}} & \mathtt{b_{40}} & \mathtt{b_{48}} & \mathtt{b_{56}} \\
\hline
\mathtt{b_1} & \mathtt{b_9} & \mathtt{b_{17}} & \mathtt{b_{25}} & \mathtt{b_{33}} & \mathtt{b_{41}} & \mathtt{b_{49}} & \mathtt{b_{57}} \\
\hline
\mathtt{b_2} & \mathtt{b_{10}} & \mathtt{b_{18}} & \mathtt{b_{26}} & \mathtt{b_{34}} & \mathtt{b_{42}} & \mathtt{b_{50}} & \mathtt{b_{58}} \\
\hline
\mathtt{b_3} & \mathtt{b_{11}} & \mathtt{b_{19}} & \mathtt{b_{27}} & \mathtt{b_{35}} & \mathtt{b_{43}} & \mathtt{b_{51}} & \mathtt{b_{59}} \\
\hline
\mathtt{b_4} & \mathtt{b_{12}} & \mathtt{b_{20}} & \mathtt{b_{28}} & \mathtt{b_{36}} & \mathtt{b_{44}} & \mathtt{b_{52}} & \mathtt{b_{60}} \\
\hline
\mathtt{b_5} & \mathtt{b_{13}} & \mathtt{b_{21}} & \mathtt{b_{29}} & \mathtt{b_{37}} & \mathtt{b_{45}} & \mathtt{b_{53}} & \mathtt{b_{61}} \\
\hline
\mathtt{b_6} & \mathtt{b_{14}} & \mathtt{b_{22}} & \mathtt{b_{30}} & \mathtt{b_{38}} & \mathtt{b_{46}} & \mathtt{b_{54}} & \mathtt{b_{62}} \\
\hline
\mathtt{b_7} & \mathtt{b_{15}} & \mathtt{b_{23}} & \mathtt{b_{31}} & \mathtt{b_{39}} & \mathtt{b_{47}} & \mathtt{b_{55}} & \mathtt{b_{63}} \\
\hline
\end{array} B 512 = b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 b 16 b 17 b 18 b 19 b 20 b 21 b 22 b 23 b 24 b 25 b 26 b 27 b 28 b 29 b 30 b 31 b 32 b 33 b 34 b 35 b 36 b 37 b 38 b 39 b 40 b 41 b 42 b 43 b 44 b 45 b 46 b 47 b 48 b 49 b 50 b 51 b 52 b 53 b 54 b 55 b 56 b 57 b 58 b 59 b 60 b 61 b 62 b 63 Substitution Box ( π ) (\pi) ( π ) We need to apply the following 8-Bit S-Box ( π : { 0 , 1 } 8 → { 0 , 1 } 8 ) (\pi:\{0,1\}^8 \to \{0,1\}^8) ( π : { 0 , 1 } 8 → { 0 , 1 } 8 ) over each byte of a column the following wayb i → π ( i m o d 4 ) [ b i ] i ∈ [ 0 , 7 ] b_i \to \pi_{(i\bmod4)}[b_i]
\hspace{3mm}i \in [0,7] b i → π ( i mod 4 ) [ b i ] i ∈ [ 0 , 7 ] b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 → π 0 [ b 0 ] π 1 [ b 1 ] π 2 [ b 2 ] π 3 [ b 3 ] π 0 [ b 4 ] π 1 [ b 5 ] π 2 [ b 6 ] π 3 [ b 7 ] \begin{array}{|c|}
\hline
\mathtt{b_0} \\
\hline
\mathtt{b_1} \\
\hline
\mathtt{b_2} \\
\hline
\mathtt{b_3 }\\
\hline
\mathtt{b_4 } \\
\hline
\mathtt{b_5} \\
\hline
\mathtt{b_6} \\
\hline
\mathtt{b_7} \\
\hline
\end{array}\to
\begin{array}{|c|}
\hline
\mathtt{\pi_0[b_0]} \\
\hline
\mathtt{\pi_1[b_{1}]} \\
\hline
\mathtt{\pi_2[b_{2}]} \\
\hline
\mathtt{\pi_3[b_{3}]} \\
\hline
\mathtt{\pi_0[b_4]} \\
\hline
\mathtt{\pi_1[b_{5}]} \\
\hline
\mathtt{\pi_2[b_{6}]} \\
\hline
\mathtt{\pi_3[b_{7}]} \\
\hline
\end{array} b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 → π 0 [ b 0 ] π 1 [ b 1 ] π 2 [ b 2 ] π 3 [ b 3 ] π 0 [ b 4 ] π 1 [ b 5 ] π 2 [ b 6 ] π 3 [ b 7 ] Shift Rows ( τ ) (\tau) ( τ ) This Byte Wise Permutation layer in the Round Function is used to add Diffusion Diffusion - Used to hide the relationship between the Ciphertext and the Plaintext We do Right Circular Shift for the rows the following way Right Circular Shift - Move the Right Most Byte of the row to the left Most and push the remaining bytes to the rightThe amount of Left Shift depends on the Row Number ( r ) (r) ( r ) and Block Size ( l ) (l) ( l ) or Number of Block Rows ( c ) (c) ( c ) - ensure that each row of the array is moved by a different number of byte positionsshift = ⌊ r × l 512 ⌋ = ⌊ r × c 8 ⌋ \text{shift} = \left\lfloor\frac{r\times l}{512} \right\rfloor
= \left\lfloor\frac{r\times c}{8}\right\rfloor shift = ⌊ 512 r × l ⌋ = ⌊ 8 r × c ⌋ b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 → b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 → b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 \begin{array}{|c|c|}
\hline
\mathtt{b_0} & \texttt{\hspace{3mm}} \\
\hline
\mathtt{b_1} & \mathtt{ } \\
\hline
\mathtt{b_2} & \mathtt{} \\
\hline
\mathtt{b_3} & \mathtt{} \\
\hline
\mathtt{b_4} & \mathtt{} \\
\hline
\mathtt{b_5} & \mathtt{} \\
\hline
\mathtt{b_6} & \mathtt{} \\
\hline
\mathtt{b_7} & \mathtt{} \\
\hline
\end{array}
\to
\begin{array}{|c|c|}
\hline
\mathtt{b_0} & \mathtt{} \\
\hline
\mathtt{b_1} & \mathtt{} \\
\hline
\mathtt{b_2} & \mathtt{} \\
\hline
\mathtt{b_3} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{b_4} \\
\hline
\mathtt{} & \mathtt{b_5} \\
\hline
\mathtt{} & \mathtt{b_6} \\
\hline
\mathtt{} & \mathtt{b_7} \\
\hline
\end{array}
\hspace{10mm}
\begin{array}{|c|c|}
\hline
\texttt{\hspace{4mm}} & \mathtt{b_8} \\
\hline
\mathtt{} & \mathtt{b_9} \\
\hline
\mathtt{} & \mathtt{b_{10}} \\
\hline
\mathtt{} & \mathtt{b_{11}} \\
\hline
\mathtt{} & \mathtt{b_{12}} \\
\hline
\mathtt{} & \mathtt{b_{13}} \\
\hline
\mathtt{} & \mathtt{b_{14}} \\
\hline
\mathtt{} & \mathtt{b_{15}} \\
\hline
\end{array} \to
\begin{array}{|c|c|}
\hline
\mathtt{} & \mathtt{b_8} \\
\hline
\mathtt{} & \mathtt{b_9} \\
\hline
\mathtt{} & \mathtt{b_{10}} \\
\hline
\mathtt{} & \mathtt{b_{11}} \\
\hline
\mathtt{b_{12}} & \mathtt{} \\
\hline
\mathtt{b_{13}} & \mathtt{} \\
\hline
\mathtt{b_{14}} & \mathtt{} \\
\hline
\mathtt{b_{15}} & \mathtt{} \\
\hline
\end{array} b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 → b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 → b 12 b 13 b 14 b 15 b 8 b 9 b 10 b 11 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 → b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 \begin{array}{|c|c|c|c|}\hline
\texttt{\hspace{4mm}} & \mathtt{b_8} & \texttt{\hspace{4mm}}&\texttt{\hspace{4mm}} \\
\hline
\mathtt{} & \mathtt{b_9} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{b_{10}} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{b_{11}} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{b_{12}} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{b_{13}} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{b_{14}} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{b_{15}} & \mathtt{} & \mathtt{} \\
\hline
\end{array} \to
\begin{array}{|c|c|c|c|}\hline
\mathtt{} & \mathtt{b_8} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{b_9} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{} & \mathtt{b_{10}} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{} & \mathtt{b_{11}} & \mathtt{} \\
\hline
\mathtt{} & \mathtt{} & \mathtt{} & \mathtt{b_{12}} \\
\hline
\mathtt{} & \mathtt{} & \mathtt{} & \mathtt{b_{13}} \\
\hline
\mathtt{b_{14}} & \mathtt{} & \mathtt{} & \mathtt{} \\
\hline
\mathtt{b_{15}} & \mathtt{} & \mathtt{} & \mathtt{} \\
\hline
\end{array} b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 → b 14 b 15 b 8 b 9 b 10 b 11 b 12 b 13 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 → b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 \begin{array}{|c|c|c|c|c|c|c|c|}
\hline
\mathtt{b_0} & \texttt{\hspace{3mm}} & \texttt{\hspace{3mm}} & \texttt{\hspace{3mm}} & \texttt{\hspace{3mm}} & \texttt{\hspace{3mm}} & \texttt{\hspace{3mm}} & \texttt{\hspace{3mm}}\\
\hline
\mathtt{b_1} & & & & & & & \\
\hline
\mathtt{b_2} & & & & & & & \\
\hline
\mathtt{b_3} & & & & & & & \\
\hline
\mathtt{b_4} & & & & & & & \\
\hline
\mathtt{b_5} & & & & & & & \\
\hline
\mathtt{b_6} & & & & & & & \\
\hline
\mathtt{b_7} & & & & & & & \\
\hline
\end{array} \to
\begin{array}{|c|c|c|c|c|c|c|c|}
\hline
\mathtt{b_0} & & & & & & & \\
\hline
& \mathtt{b_1} & & & & & & \\
\hline
& & \mathtt{b_2} & & & & & \\
\hline
& & & \mathtt{b_3} & & & & \\
\hline
& & & & \mathtt{b_4} & & & \\
\hline
& & & & & \mathtt{b_5} & & \\
\hline
& & & & & &\mathtt{b_6} & \\
\hline
& & & & & & & \mathtt{b_7} \\
\hline
\end{array} b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 → b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 Mix Columns ( ψ ) (\psi) ( ψ ) Mixes each column of the State Matrix We do a Matrix-Vector Multiplication with the Column C = [ b 0 , b 1 , b 2 , b 3 , b 4 , b 5 , b 6 , b 7 ] C = [b_0,b_1,b_2,b_3,b_4,b_5,b_6,b_7] C = [ b 0 , b 1 , b 2 , b 3 , b 4 , b 5 , b 6 , b 7 ] and an MDS Matrix M M M to give the resultant column vector C = [ d 0 , d 1 , d 2 , d 3 , d 4 , d 5 , d 6 , d 7 ] C = [d_0,d_1,d_2,d_3,d_4,d_5,d_6,d_7] C = [ d 0 , d 1 , d 2 , d 3 , d 4 , d 5 , d 6 , d 7 ] that is within a Galois Field G F ( 2 8 ) GF(2^8) GF ( 2 8 ) [ 01 01 05 01 08 06 07 04 04 01 01 05 01 08 06 07 07 04 01 01 05 01 08 06 06 07 04 01 01 05 01 08 08 06 07 04 01 01 05 01 01 08 06 07 04 01 01 05 05 01 08 06 07 04 01 01 01 05 01 08 06 07 04 01 ] [ b 0 b 1 b 2 b 3 b 4 b 6 b 6 b 7 ] = [ d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 ] \begin{bmatrix}
\mathtt{01} & \mathtt{01} & \mathtt{05} & \mathtt{01} & \mathtt{08} & \mathtt{06} &\mathtt{07} & \mathtt{04}\\
\mathtt{04} & \mathtt{01} & \mathtt{01} & \mathtt{05} & \mathtt{01} & \mathtt{08} & \mathtt{06} &\mathtt{07}\\
\mathtt{07} & \mathtt{04} & \mathtt{01} & \mathtt{01} & \mathtt{05} & \mathtt{01} & \mathtt{08} & \mathtt{06}\\
\mathtt{06} &\mathtt{07} & \mathtt{04} & \mathtt{01} & \mathtt{01} & \mathtt{05} & \mathtt{01} & \mathtt{08}\\
\mathtt{08} & \mathtt{06} &\mathtt{07} & \mathtt{04} & \mathtt{01} & \mathtt{01} & \mathtt{05} & \mathtt{01}\\
\mathtt{01} & \mathtt{08} & \mathtt{06} &\mathtt{07} & \mathtt{04} & \mathtt{01} & \mathtt{01} & \mathtt{05}\\
\mathtt{05} & \mathtt{01} & \mathtt{08} & \mathtt{06} &\mathtt{07} & \mathtt{04} & \mathtt{01} & \mathtt{01}\\
\mathtt{01} & \mathtt{05} & \mathtt{01} & \mathtt{08} & \mathtt{06} &\mathtt{07} & \mathtt{04} & \mathtt{01}\\
\end{bmatrix}
\begin{bmatrix}
b_0\\b_1\\b_2\\b_3 \\ b_4\\b_6\\b_6\\b_7
\end{bmatrix} = \begin{bmatrix}d_0\\d_1\\d_2\\d_3\\d_4\\d_5\\d_6\\d_7
\end{bmatrix} ⎣ ⎡ 01 04 07 06 08 01 05 01 01 01 04 07 06 08 01 05 05 01 01 04 07 06 08 01 01 05 01 01 04 07 06 08 08 01 05 01 01 04 07 06 06 08 01 05 01 01 04 07 07 06 08 01 05 01 01 04 04 07 06 08 01 05 01 01 ⎦ ⎤ ⎣ ⎡ b 0 b 1 b 2 b 3 b 4 b 6 b 6 b 7 ⎦ ⎤ = ⎣ ⎡ d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 ⎦ ⎤ The inverse of this MDS Matrix is used while decrypting [ b 0 b 1 b 2 b 3 b 4 b 6 b 6 b 7 ] = [ A D 95 76 A 8 2 F 49 D 7 C A C A A D 95 76 A 8 2 F 49 D 7 D 7 C A A D 95 76 A 8 2 F 49 49 D 7 C A A D 95 76 A 8 2 F 2 F 49 D 7 C A A D 95 76 A 8 A 8 2 F 49 D 7 C A A D 95 76 76 A 8 2 F 49 D 7 C A A D 95 95 76 A 8 2 F 49 D 7 C A A D ] [ d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 ] \begin{bmatrix}
b_0\\b_1\\b_2\\b_3 \\ b_4\\b_6\\b_6\\b_7
\end{bmatrix} =
\begin{bmatrix}
\mathtt{AD} & \mathtt{95} & \mathtt{76} & \mathtt{A8} & \mathtt{2F} & \mathtt{49} &\mathtt{D7} & \mathtt{CA}\\
\mathtt{CA} & \mathtt{AD} & \mathtt{95} & \mathtt{76} & \mathtt{A8} & \mathtt{2F} & \mathtt{49} &\mathtt{D7} \\
\mathtt{D7} & \mathtt{CA} &\mathtt{AD} & \mathtt{95} & \mathtt{76} & \mathtt{A8} & \mathtt{2F} & \mathtt{49}\\
\mathtt{49} & \mathtt{D7} & \mathtt{CA} & \mathtt{AD} & \mathtt{95} & \mathtt{76} & \mathtt{A8} & \mathtt{2F}\\
\mathtt{2F} & \mathtt{49} & \mathtt{D7} & \mathtt{CA} &\mathtt{AD} & \mathtt{95} & \mathtt{76} & \mathtt{A8}\\
\mathtt{A8} & \mathtt{2F} & \mathtt{49} & \mathtt{D7} & \mathtt{CA} & \mathtt{AD} & \mathtt{95} & \mathtt{76}\\
\mathtt{76} & \mathtt{A8} & \mathtt{2F} & \mathtt{49} & \mathtt{D7} & \mathtt{CA} &\mathtt{AD} & \mathtt{95}\\
\mathtt{95} & \mathtt{76} & \mathtt{A8} & \mathtt{2F} & \mathtt{49} & \mathtt{D7} & \mathtt{CA} & \mathtt{AD}\\
\end{bmatrix}
\begin{bmatrix}d_0\\d_1\\d_2\\d_3\\d_4\\d_5\\d_6\\d_7
\end{bmatrix} ⎣ ⎡ b 0 b 1 b 2 b 3 b 4 b 6 b 6 b 7 ⎦ ⎤ = ⎣ ⎡ AD CA D7 49 2F A8 76 95 95 AD CA D7 49 2F A8 76 76 95 AD CA D7 49 2F A8 A8 76 95 AD CA D7 49 2F 2F A8 76 95 AD CA D7 49 49 2F A8 76 95 AD CA D7 D7 49 2F A8 76 95 AD CA CA D7 49 2F A8 76 95 AD ⎦ ⎤ ⎣ ⎡ d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 ⎦ ⎤ XOR \operatorname{XOR} XOR Round Key ( κ l K v ) (\kappa_l^{K_v}) ( κ l K v ) In this operation we XOR \operatorname{XOR} XOR the State matrix of block size l l l bits with the v t h v^{th} v t h Round Key K v K_v K v derived from Key Expansion . The Round Keys have the same size as the Block even though the Master Key might differ in size. This is explained in Key Expansion in great detail. For a 128 128 128 bit block size round key K 128 K_{128} K 128 is defined the following way.K 128 = k 0 k 8 k 1 k 9 k 2 k 10 k 3 k 11 k 4 k 12 k 5 k 13 k 6 k 14 k 7 k 15 K_{128} = \begin{array}{|c|c|}
\hline
\mathtt{k_0} & \mathtt{k_8} \\
\hline
\mathtt{k_1} & \mathtt{k_9} \\
\hline
\mathtt{k_2} & \mathtt{k_{10}} \\
\hline
\mathtt{k_3} & \mathtt{k_{11}} \\
\hline
\mathtt{k_4} & \mathtt{k_{12}} \\
\hline
\mathtt{k_5} & \mathtt{k_{13}} \\
\hline
\mathtt{k_6} & \mathtt{k_{14}} \\
\hline
\mathtt{k_7} & \mathtt{k_{15}} \\
\hline
\end{array}
\hspace{5mm} K 128 = k 0 k 1 k 2 k 3 k 4 k 5 k 6 k 7 k 8 k 9 k 10 k 11 k 12 k 13 k 14 k 15 The XOR \text{XOR} XOR operation is done Byte wise the following way b 0 b 8 b 1 b 9 b 2 b 10 b 3 b 11 b 4 b 12 b 5 b 13 b 6 b 14 b 7 b 15 ⊕ k 0 k 8 k 1 k 9 k 2 k 10 k 3 k 11 k 4 k 12 k 5 k 13 k 6 k 14 k 7 k 15 = b 0 ⊕ k 0 b 8 ⊕ k 8 b 1 ⊕ k 1 b 9 ⊕ k 9 b 2 ⊕ k 2 b 10 ⊕ k 10 b 3 ⊕ k 3 b 11 ⊕ k 11 b 4 ⊕ k 4 b 12 ⊕ k 12 b 5 ⊕ k 5 b 13 ⊕ k 13 b 6 ⊕ k 6 b 14 ⊕ k 14 b 7 ⊕ k 7 b 15 ⊕ k 15 \begin{array}{|c|c|}
\hline
\mathtt{b_0} & \mathtt{b_8} \\
\hline
\mathtt{b_1} & \mathtt{b_9} \\
\hline
\mathtt{b_2} & \mathtt{b_{10}} \\
\hline
\mathtt{b_3} & \mathtt{b_{11}} \\
\hline
\mathtt{b_4} & \mathtt{b_{12}} \\
\hline
\mathtt{b_5} & \mathtt{b_{13}} \\
\hline
\mathtt{b_6} & \mathtt{b_{14}} \\
\hline
\mathtt{b_7} & \mathtt{b_{15}} \\
\hline
\end{array} \oplus \begin{array}{|c|c|}
\hline
\mathtt{k_0} & \mathtt{k_8} \\
\hline
\mathtt{k_1} & \mathtt{k_9} \\
\hline
\mathtt{k_2} & \mathtt{k_{10}} \\
\hline
\mathtt{k_3} & \mathtt{k_{11}} \\
\hline
\mathtt{k_4} & \mathtt{k_{12}} \\
\hline
\mathtt{k_5} & \mathtt{k_{13}} \\
\hline
\mathtt{k_6} & \mathtt{k_{14}} \\
\hline
\mathtt{k_7} & \mathtt{k_{15}} \\
\hline
\end{array}
= \begin{array}{|c|c|}
\hline
\mathtt{b_0 \oplus k_0} & \mathtt{b_8 \oplus k_8} \\
\hline
\mathtt{b_1 \oplus k_1} & \mathtt{b_9 \oplus k_9} \\
\hline
\mathtt{b_2 \oplus k_2} & \mathtt{b_{10} \oplus k_{10}} \\
\hline
\mathtt{b_3 \oplus k_3} & \mathtt{b_{11} \oplus k_{11}} \\
\hline
\mathtt{b_4 \oplus k_4} & \mathtt{b_{12} \oplus k_{12}} \\
\hline
\mathtt{b_5 \oplus k_5} & \mathtt{b_{13} \oplus k_{13}} \\
\hline
\mathtt{b_6 \oplus k_6} & \mathtt{b_{14} \oplus k_{14}} \\
\hline
\mathtt{b_7 \oplus k_7} & \mathtt{b_{15} \oplus k_{15}} \\
\hline
\end{array} b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 ⊕ k 0 k 1 k 2 k 3 k 4 k 5 k 6 k 7 k 8 k 9 k 10 k 11 k 12 k 13 k 14 k 15 = b 0 ⊕ k 0 b 1 ⊕ k 1 b 2 ⊕ k 2 b 3 ⊕ k 3 b 4 ⊕ k 4 b 5 ⊕ k 5 b 6 ⊕ k 6 b 7 ⊕ k 7 b 8 ⊕ k 8 b 9 ⊕ k 9 b 10 ⊕ k 10 b 11 ⊕ k 11 b 12 ⊕ k 12 b 13 ⊕ k 13 b 14 ⊕ k 14 b 15 ⊕ k 15 Add Round Key ( η l K v ) (\eta_l^{K_v}) ( η l K v ) Add Round Key is a new operation introduced in Kalyna unlike the previous ones mentioned which are extensions over AES \text{AES} AES round operations. It is denoted by ⊞ \boxplus ⊞ . In this we again take the State Matrix of block size l l l bits and combine with v t h v^{th} v t h Round Key K v K_v K v derived from Key Expansion by doing a addition modulus 2 64 2^{64} 2 64 It is done Column Wise - We take each column ( 8 (8 ( 8 bytes - 64 64 64 Bits) of the State matrix and add them with the corresponding columns of the Round Key under addition modulus 2 64 2^{64} 2 64 The Column is arranged in Little Endian Form - Smaller Indexed Bytes are the Least Significant Bytes For instance, for a 128 128 128 State Matrix B 128 B_{128} B 128 and Round Key K 128 K_{128} K 128 we do addition the following way. b 0 b 8 b 1 b 9 b 2 b 10 b 3 b 11 b 4 b 12 b 5 b 13 b 6 b 14 b 7 b 15 ⊞ k 0 k 8 k 1 k 9 k 2 k 10 k 3 k 11 k 4 k 12 k 5 k 13 k 6 k 14 k 7 k 15 ↓ b 7 ∣ ∣ b 6 ∣ ∣ b 5 ∣ ∣ b 4 ∣ ∣ b 3 ∣ ∣ b 2 ∣ ∣ b 1 ∣ ∣ b 0 b 15 ∣ ∣ b 14 ∣ ∣ b 13 ∣ ∣ b 12 ∣ ∣ b 11 ∣ ∣ b 10 ∣ ∣ b 9 ∣ ∣ b 8 ∣ ⊞ ⊞ k 7 ∣ ∣ k 6 ∣ ∣ k 5 ∣ ∣ k 4 ∣ ∣ k 3 ∣ ∣ k 2 ∣ ∣ k 1 ∣ ∣ k 0 k 15 ∣ ∣ k 14 ∣ ∣ k 13 ∣ ∣ k 12 ∣ ∣ k 11 ∣ ∣ k 10 ∣ ∣ k 9 ∣ ∣ k 8 ∣ ↓ c 0 c 8 c 1 c 9 c 2 c 10 c 3 c 11 c 4 c 12 c 5 c 13 c 6 c 14 c 7 c 15 \begin{array}{|c|c|}
\hline
\mathtt{b_0} & \mathtt{b_8} \\
\hline
\mathtt{b_1} & \mathtt{b_9} \\
\hline
\mathtt{b_2} & \mathtt{b_{10}} \\
\hline
\mathtt{b_3} & \mathtt{b_{11}} \\
\hline
\mathtt{b_4} & \mathtt{b_{12}} \\
\hline
\mathtt{b_5} & \mathtt{b_{13}} \\
\hline
\mathtt{b_6} & \mathtt{b_{14}} \\
\hline
\mathtt{b_7} & \mathtt{b_{15}} \\
\hline
\end{array} \boxplus \begin{array}{|c|c|}
\hline
\mathtt{k_0} & \mathtt{k_8} \\
\hline
\mathtt{k_1} & \mathtt{k_9} \\
\hline
\mathtt{k_2} & \mathtt{k_{10}} \\
\hline
\mathtt{k_3} & \mathtt{k_{11}} \\
\hline
\mathtt{k_4} & \mathtt{k_{12}} \\
\hline
\mathtt{k_5} & \mathtt{k_{13}} \\
\hline
\mathtt{k_6} & \mathtt{k_{14}} \\
\hline
\mathtt{k_7} & \mathtt{k_{15}} \\
\hline
\end{array}\\
\downarrow\\
\begin{array}{|c|c|}
\hline
\mathtt{b_7||b_6||b_5||b_4||b_3||b_2||b_1||b_0} &
\mathtt{b_{15}||b_{14}||b_{13}||b_{12}||b_{11}||b_{10}||b_9||b_8|} \\
\boxplus & \boxplus\\
\mathtt{k_7||k_6||k_5||k_4||k_3||k_2||k_1||k_0} &
\mathtt{k_{15}||k_{14}||k_{13}||k_{12}||k_{11}||k_{10}||k_9||k_8|}\\
\hline
\end{array}\\
\downarrow\\
\begin{array}{|c|c|}
\hline
\mathtt{c_0} & \mathtt{c_8} \\
\hline
\mathtt{c_1} & \mathtt{c_9} \\
\hline
\mathtt{c_2} & \mathtt{c_{10}} \\
\hline
\mathtt{c_3} & \mathtt{c_{11}} \\
\hline
\mathtt{c_4} & \mathtt{c_{12}} \\
\hline
\mathtt{c_5} & \mathtt{c_{13}} \\
\hline
\mathtt{c_6} & \mathtt{c_{14}} \\
\hline
\mathtt{c_7} & \mathtt{c_{15}} \\
\hline
\end{array} b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 ⊞ k 0 k 1 k 2 k 3 k 4 k 5 k 6 k 7 k 8 k 9 k 10 k 11 k 12 k 13 k 14 k 15 ↓ b 7 ∣∣ b 6 ∣∣ b 5 ∣∣ b 4 ∣∣ b 3 ∣∣ b 2 ∣∣ b 1 ∣∣ b 0 ⊞ k 7 ∣∣ k 6 ∣∣ k 5 ∣∣ k 4 ∣∣ k 3 ∣∣ k 2 ∣∣ k 1 ∣∣ k 0 b 15 ∣∣ b 14 ∣∣ b 13 ∣∣ b 12 ∣∣ b 11 ∣∣ b 10 ∣∣ b 9 ∣∣ b 8 ∣ ⊞ k 15 ∣∣ k 14 ∣∣ k 13 ∣∣ k 12 ∣∣ k 11 ∣∣ k 10 ∣∣ k 9 ∣∣ k 8 ∣ ↓ c 0 c 1 c 2 c 3 c 4 c 5 c 6 c 7 c 8 c 9 c 10 c 11 c 12 c 13 c 14 c 15